package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.comment.FileComment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BEAfanjuanMapper;
import com.ruoyi.system.domain.BEAfanjuan;
import com.ruoyi.system.service.IBEAfanjuanService;


import com.ruoyi.system.domain.BEAfeng;
import com.ruoyi.system.mapper.BEAfengMapper;

import com.ruoyi.system.domain.comment.VolumeComment;

/**
 * 案卷管理审核后Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-24
 */
@Service
public class BEAfanjuanServiceImpl implements IBEAfanjuanService 
{
    @Autowired
    private BEAfanjuanMapper bEAfanjuanMapper;

    @Autowired
    private BEAfengMapper bEAfengMapper;
    /**
     * 查询案卷管理审核后
     * 
     * @param id 案卷管理审核后主键
     * @return 案卷管理审核后
     */
    @Override
    public BEAfanjuan selectBEAfanjuanById(String id)
    {
        return bEAfanjuanMapper.selectBEAfanjuanById(id);
    }


    /**
     * 查询案卷注释信息列表
     *
     * @return 案卷信息集合
     */
    public List<VolumeComment> selectBEAfanjuanComList(){
        return bEAfanjuanMapper.selectBEAfanjuanComList();
    }



    /**
     * 查询案卷管理审核后列表
     * 
     * @param bEAfanjuan 案卷管理审核后
     * @return 案卷管理审核后
     */
    @Override
    public List<BEAfanjuan> selectBEAfanjuanList(BEAfanjuan bEAfanjuan)
    {
        return bEAfanjuanMapper.selectBEAfanjuanList(bEAfanjuan);
    }

    /**
     * 新增案卷管理审核后
     * 
     * @param bEAfanjuan 案卷管理审核后
     * @return 结果
     */

    @Override
    public int insertBEAfanjuan(BEAfanjuan bEAfanjuan)
    {
        // 添加详细日志记录
        System.out.println("Inserting b_e_afanjuan with eeid: " + bEAfanjuan.getEeid());
        System.out.println("bEAfanjuan details: " + bEAfanjuan.toString());

        // 检查 b_e_afeng 表中是否存在 eeid 值
        BEAfeng bEAfeng = bEAfengMapper.selectBEAfengById(bEAfanjuan.getEeid());
        if (bEAfeng == null) {
            throw new RuntimeException("对应的 b_e_afeng 记录不存在，无法插入 b_e_afanjuan 记录");
        }

        System.out.println("Corresponding b_e_afeng record found: " + bEAfeng.toString());

        int result = bEAfanjuanMapper.insertBEAfanjuan(bEAfanjuan);

        System.out.println("Insert operation result: " + result);

        return result;
    }


    /**
     * 修改案卷管理审核后
     * 
     * @param bEAfanjuan 案卷管理审核后
     * @return 结果
     */
    @Override
    public int updateBEAfanjuan(BEAfanjuan bEAfanjuan)
    {
        return bEAfanjuanMapper.updateBEAfanjuan(bEAfanjuan);
    }

    /**
     * 批量删除案卷管理审核后
     * 
     * @param ids 需要删除的案卷管理审核后主键
     * @return 结果
     */
    @Override
    public int deleteBEAfanjuanByIds(String[] ids)
    {
        return bEAfanjuanMapper.deleteBEAfanjuanByIds(ids);
    }

    /**
     * 删除案卷管理审核后信息
     * 
     * @param id 案卷管理审核后主键
     * @return 结果
     */
    @Override
    public int deleteBEAfanjuanById(String id)
    {
        return bEAfanjuanMapper.deleteBEAfanjuanById(id);
    }
}
